package com.modules.flexnet.control.commands
{
	import com.adobe.cairngorm.control.CairngormEvent;
	import com.arc90.modular.ModuleSequenceCommand;
	import com.modules.flexnet.business.delegates.ProductDataDelegate;
	import com.modules.flexnet.control.events.GetProductDataEvent;
	import com.modules.flexnet.model.ModuleModelLocator;
	
	import mx.collections.ArrayCollection;
	import mx.controls.Alert;
	import mx.rpc.IResponder;
	
	/**
	 * @version $Revision: $
	 */
	
	public class GetProductDataCommand extends ModuleSequenceCommand implements IResponder
	{  
		private var appModel:ModuleModelLocator = ModuleModelLocator.getInstance(); 
		
	 	public function GetProductDataCommand()
	 	{
	 	
		}    
	  	override public function execute( event : CairngormEvent ) : void
   		{
			var delegate:ProductDataDelegate = new ProductDataDelegate(this);
			var dataEvent:GetProductDataEvent = GetProductDataEvent(event);
			delegate.getProducts();
   		}
   		//default Cairngorm interface
   		/*public function onResult(e:* = null):void
   		{
   			trace(e);
   		}
   		public function onFault(e:* = null):void
   		{
   			Alert.show("Fault",  e.fault.toString());
   		}*/
   		// default Flex interface
   		public function result(e:Object):void
   		{
   			appModel.productModel.products = e.result as ArrayCollection;
   		}
   		public function fault(e:Object):void
   		{
   			Alert.show("Fault",  e.fault.toString());
   		}
	}
}